﻿@{
    ViewBag.Title = Model[0].Title;
}
<div class="product-detail mt10">
    <h2 class="product-title bgwhite black ml5 mr5"> @Model[0].Title</h2>
        <form id="cart-form" class="cart-form" data-ajax="false" method="post" action="~/Purchase/CheckOut">
            <div class="ui-grid-a p10_0 mt5">
                <div class="ui-block-a ">
                    <img alt="" src="@Model[0].ActualImageUrl" class="product-image" />
                </div>

                <div class="ui-block-b">
                    <div class="service_rating ml20">
                        <div class="rating fl">
                            <div style="width: 80%;" class="value" rating="TotalBest"></div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="price f20 mt10 ml20">￥@Model[0].UnitPrice</div>
                    <div class="clear"></div>
                    <div class="price-delivery mt10 pl25"> 

                        @if (!string.IsNullOrEmpty(@Model[0].PromotionDescription))
                        {
                            <div class="viewdesc normalwrap">
                                <ul>
                                    <li><span class="red f15">@Model[0].PromotionDescription</span></li>
                                </ul>
                            </div>
                        }
                        <div class="mt5">
                            <div class="ItemQty">
                                <div class="ReduceTable fl">
                                    <div class="Reduce gradientBlue2 mt5">
                                        <a href="#"  id="pndbtnReduce"> <div class="Reduceicon"></div></a>
                                    </div>
                                </div>
                                <input  id="quantity" class="fl mt10 " type="number" name="quantity" value="1" data-theme="none" maxlength="3"  />
                                <div class="AddTable fl">
                                    <div class="add gradientBlue2 mt5">
                                        <a href="#" id="pndbtnAdd"> <div class="addicon"></div></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            @if (Model[0].TotalInventory > 0)
            {
                <div class="ui-grid-a">
                    <div class="ui-block-a">
                       <a href="#" onclick="AddToCart()" data-theme="e" data-role="button" >加入购物车</a>
                    </div>
                    <div class="ui-block-b">
                         <input type="submit" data-role="button" id="btnToCheckOut" value="立即购买" data-theme="f"></input>
                    </div>
		        </div>
            }
            else
            {
                <a href="#" data-role="button">暂时缺货</a>
            }
            <p></p>
            <div class="clear mt20"></div>
        	<span class="product-title black">@Model[0].LineDescription</span>
            <div class="clear mb20"></div>
            <p></p>
	</form>
</div>
<div data-role="collapsible-set">
    <div class="product-info" data-role="collapsible" data-collapsed="false">
        <h2>规格参数</h2>
        <div class="center product_desc" aria-hidden="false">
            @Html.Raw(@Model[0].DetailSpecification)
        </div>
    </div>
</div>
<div data-role="collapsible-set">
    <div class="product-info" data-role="collapsible">
        <h2>商品实拍</h2>
        <div class="center product_images" aria-hidden="false">
            @foreach (var item in Model[0].ImageList)
            {
                <img src="@item.ImageName" />
            }
        </div>
    </div>
</div>
<div data-role="collapsible-set">
    <div class="product-info" data-role="collapsible" id="product_over">
        <h2>商品描述</h2>
        <div class="product_overview">
            @Html.Raw(@Model[0].Overview)
        </div>
    </div>
</div>
<div data-role="collapsible-set">
    <div class="product-info" data-role="collapsible">
        <h2>用户评价</h2>
        <div class="center product_images" aria-hidden="false">
            <ul class="product_reports" id="ul_product_reports">
                <li>
                    @if (@Model[0].ProductReviewList.Count == 0)
                    {
                        @Html.Raw("暂无评价");
                    }
                    @foreach (var item in @Model[0].ProductReviewList)
                    {
                        <div class="report">
                            <div class="report_title">
                                <div class="avatar">
                                    <img src="http://image5.suning.cn/css/ShoppingArea/V8/images/default50.png" alt="@item.CustomerName - @item.RankName" />
                                    <div class="user_info">
                                        <span class="user_name">@item.CustomerName</span>
                                        <span class="user_level"><span class="gold">@item.RankName</span></span>
                                    </div>
                                </div>
                                <div style="padding-left: 0px;">
                                    <div class="service_rating">
                                        <div class="rating fl">
                                            <div style="width: @item*20 %;" class="value" rating="TotalBest"></div>
                                        </div>
                                        <span class="ml5 fl">@item.InDateFormated</span>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                                <h3>@item.Title</h3>
                            </div>
                            <div class="desc">
                                <p>
                                </p>
                                <dl>
                                    <dt>
                                        <h4>使用心得：</h4>
                                    </dt>
                                    <dd>@item.MeritText</dd>
                                </dl>
                                <dl>
                                    <dt>
                                        <h4>不足：</h4>
                                    </dt>
                                    <dd>@item.FaultsText</dd>
                                </dl>

                                <dl>
                                    <dt>
                                        <h4>优点及建议：</h4>
                                    </dt>
                                    <dd>@item.ImproveText</dd>
                                </dl>
                                <p></p>
                            </div>
                        </div>
                    }

                </li>
            </ul>
        </div>
    </div>
</div>
 <a href="#" onclick="AddFavority(@Model[0].ProductId,@Model[0].MarketPrice,'~/Product/ProductDetail?prd=@Model[0].ProductId')" 
                    data-role="button" data-theme="a">添加关注</a>
<script language="javascript" type="text/javascript">
    var AddToCart = function() {
        try {
            var qty = $("#quantity").val();
            KevinShop.Common.ShoppingCart.UpdateToCart('@Model[0].ProductId', qty);
            KevinShop.MessageBox.Success("添加到购物车成功！");
        } catch(e) {
            alert(e);
        }
    };
    var AddFavority = function($productId, $marketPrice, $returnUrl) {
        var $url = "AddFavority?productId=" + $productId + "&marketPrice=" + $marketPrice + "&returnUrl=" + $returnUrl;
        var $result = $.ajax({
            url: $url,
            async: false
        }).responseText;

        $result = $.parseJSON($result);

        if ($result.Status == true && $result.ErrorMessage == "ok") {
            KevinShop.MessageBox.Success("关注成功！");
        } else if ($result.Status == false && $result.ErrorStatusCode == "404") {
            window.location.href = "../Customer/Login?ReturnUrl=" + $result.ErrorMessage;
        } else if ($result.ErrorMessage == "existsProduct") {
            KevinShop.MessageBox.Warning("您已关注过此商品");
        } else {
            KevinShop.MessageBox.Warning($result.ErrorMessage);
        }
    };

        $("#pndbtnReduce").click(function () {
            var qtyText = $("#quantity").val();
            var qty = parseInt(qtyText);
            if (qty > 1) {
                qty--;
            }else {
                KevinShop.MessageBox.Alert("亲，不能再减啦。");
            };
            $("#quantity").val(qty);
        });
        $("#pndbtnAdd").click(function () {
            var qtyText = $("#quantity").val();
            var qty = parseInt(qtyText);
            if (qty < 999) {
                qty++;
            };
            $("#quantity").val(qty);
        });
        $("#btnToCheckOut").click(function () {
            var qty = $("#quantity").val();
            KevinShop.Common.ShoppingCart.UpdateToCart('@Model[0].ProductId', qty);
            $("#cart-form").submitForm();
            return false;
        });
    $(".product_overview img").attr("width", "100%");
    $(".product_overview img").removeAttr("height");
</script>